\(\int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx\) [686]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [F(-2)]
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 41, antiderivative size = 91 \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=-\frac {a^2 (i A+B)}{2 c^4 f (i+\tan (e+f x))^4}+\frac {a^2 (A-3 i B)}{3 c^4 f (i+\tan (e+f x))^3}+\frac {a^2 B}{2 c^4 f (i+\tan (e+f x))^2} \]

[Out]

-1/2*a^2*(I*A+B)/c^4/f/(I+tan(f*x+e))^4+1/3*a^2*(A-3*I*B)/c^4/f/(I+tan(f*x+e))^3+1/2*a^2*B/c^4/f/(I+tan(f*x+e)
)^2

Rubi [A] (verified)

Time = 0.16 (sec) , antiderivative size = 91, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.049, Rules used = {3669, 78} \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=\frac {a^2 (A-3 i B)}{3 c^4 f (\tan (e+f x)+i)^3}-\frac {a^2 (B+i A)}{2 c^4 f (\tan (e+f x)+i)^4}+\frac {a^2 B}{2 c^4 f (\tan (e+f x)+i)^2} \]

[In]

Int[((a + I*a*Tan[e + f*x])^2*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^4,x]

[Out]

-1/2*(a^2*(I*A + B))/(c^4*f*(I + Tan[e + f*x])^4) + (a^2*(A - (3*I)*B))/(3*c^4*f*(I + Tan[e + f*x])^3) + (a^2*
B)/(2*c^4*f*(I + Tan[e + f*x])^2)

Rule 78

Int[((a_.) + (b_.)*(x_))*((c_) + (d_.)*(x_))^(n_.)*((e_.) + (f_.)*(x_))^(p_.), x_Symbol] :> Int[ExpandIntegran
d[(a + b*x)*(c + d*x)^n*(e + f*x)^p, x], x] /; FreeQ[{a, b, c, d, e, f, n}, x] && NeQ[b*c - a*d, 0] && ((ILtQ[
n, 0] && ILtQ[p, 0]) || EqQ[p, 1] || (IGtQ[p, 0] && ( !IntegerQ[n] || LeQ[9*p + 5*(n + 2), 0] || GeQ[n + p + 1
, 0] || (GeQ[n + p + 2, 0] && RationalQ[a, b, c, d, e, f]))))

Rule 3669

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a*(c/f), Subst[Int[(a + b*x)^(m - 1)*(c + d*x)^(n - 1)*(A + B*x), x
], x, Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, A, B, m, n}, x] && EqQ[b*c + a*d, 0] && EqQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(a c) \text {Subst}\left (\int \frac {(a+i a x) (A+B x)}{(c-i c x)^5} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {(a c) \text {Subst}\left (\int \left (\frac {2 a (i A+B)}{c^5 (i+x)^5}-\frac {a (A-3 i B)}{c^5 (i+x)^4}-\frac {a B}{c^5 (i+x)^3}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {a^2 (i A+B)}{2 c^4 f (i+\tan (e+f x))^4}+\frac {a^2 (A-3 i B)}{3 c^4 f (i+\tan (e+f x))^3}+\frac {a^2 B}{2 c^4 f (i+\tan (e+f x))^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 5.30 (sec) , antiderivative size = 51, normalized size of antiderivative = 0.56 \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=\frac {a^2 \left (-i A+2 A \tan (e+f x)+3 B \tan ^2(e+f x)\right )}{6 c^4 f (i+\tan (e+f x))^4} \]

[In]

Integrate[((a + I*a*Tan[e + f*x])^2*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^4,x]

[Out]

(a^2*((-I)*A + 2*A*Tan[e + f*x] + 3*B*Tan[e + f*x]^2))/(6*c^4*f*(I + Tan[e + f*x])^4)

Maple [A] (verified)

Time = 0.15 (sec) , antiderivative size = 68, normalized size of antiderivative = 0.75

method result size
derivativedivides \(\frac {a^{2} \left (-\frac {2 i A +2 B}{4 \left (i+\tan \left (f x +e \right )\right )^{4}}-\frac {3 i B -A}{3 \left (i+\tan \left (f x +e \right )\right )^{3}}+\frac {B}{2 \left (i+\tan \left (f x +e \right )\right )^{2}}\right )}{f \,c^{4}}\) \(68\)
default \(\frac {a^{2} \left (-\frac {2 i A +2 B}{4 \left (i+\tan \left (f x +e \right )\right )^{4}}-\frac {3 i B -A}{3 \left (i+\tan \left (f x +e \right )\right )^{3}}+\frac {B}{2 \left (i+\tan \left (f x +e \right )\right )^{2}}\right )}{f \,c^{4}}\) \(68\)
risch \(-\frac {a^{2} {\mathrm e}^{8 i \left (f x +e \right )} B}{32 c^{4} f}-\frac {i a^{2} {\mathrm e}^{8 i \left (f x +e \right )} A}{32 c^{4} f}-\frac {i A \,a^{2} {\mathrm e}^{6 i \left (f x +e \right )}}{12 c^{4} f}+\frac {a^{2} {\mathrm e}^{4 i \left (f x +e \right )} B}{16 c^{4} f}-\frac {i a^{2} {\mathrm e}^{4 i \left (f x +e \right )} A}{16 c^{4} f}\) \(110\)

[In]

int((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^4,x,method=_RETURNVERBOSE)

[Out]

1/f*a^2/c^4*(-1/4*(2*B+2*I*A)/(I+tan(f*x+e))^4-1/3*(-A+3*I*B)/(I+tan(f*x+e))^3+1/2*B/(I+tan(f*x+e))^2)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 64, normalized size of antiderivative = 0.70 \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=-\frac {3 \, {\left (i \, A + B\right )} a^{2} e^{\left (8 i \, f x + 8 i \, e\right )} + 8 i \, A a^{2} e^{\left (6 i \, f x + 6 i \, e\right )} + 6 \, {\left (i \, A - B\right )} a^{2} e^{\left (4 i \, f x + 4 i \, e\right )}}{96 \, c^{4} f} \]

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^4,x, algorithm="fricas")

[Out]

-1/96*(3*(I*A + B)*a^2*e^(8*I*f*x + 8*I*e) + 8*I*A*a^2*e^(6*I*f*x + 6*I*e) + 6*(I*A - B)*a^2*e^(4*I*f*x + 4*I*
e))/(c^4*f)

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 218 vs. \(2 (73) = 146\).

Time = 0.33 (sec) , antiderivative size = 218, normalized size of antiderivative = 2.40 \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=\begin {cases} \frac {- 512 i A a^{2} c^{8} f^{2} e^{6 i e} e^{6 i f x} + \left (- 384 i A a^{2} c^{8} f^{2} e^{4 i e} + 384 B a^{2} c^{8} f^{2} e^{4 i e}\right ) e^{4 i f x} + \left (- 192 i A a^{2} c^{8} f^{2} e^{8 i e} - 192 B a^{2} c^{8} f^{2} e^{8 i e}\right ) e^{8 i f x}}{6144 c^{12} f^{3}} & \text {for}\: c^{12} f^{3} \neq 0 \\\frac {x \left (A a^{2} e^{8 i e} + 2 A a^{2} e^{6 i e} + A a^{2} e^{4 i e} - i B a^{2} e^{8 i e} + i B a^{2} e^{4 i e}\right )}{4 c^{4}} & \text {otherwise} \end {cases} \]

[In]

integrate((a+I*a*tan(f*x+e))**2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))**4,x)

[Out]

Piecewise(((-512*I*A*a**2*c**8*f**2*exp(6*I*e)*exp(6*I*f*x) + (-384*I*A*a**2*c**8*f**2*exp(4*I*e) + 384*B*a**2
*c**8*f**2*exp(4*I*e))*exp(4*I*f*x) + (-192*I*A*a**2*c**8*f**2*exp(8*I*e) - 192*B*a**2*c**8*f**2*exp(8*I*e))*e
xp(8*I*f*x))/(6144*c**12*f**3), Ne(c**12*f**3, 0)), (x*(A*a**2*exp(8*I*e) + 2*A*a**2*exp(6*I*e) + A*a**2*exp(4
*I*e) - I*B*a**2*exp(8*I*e) + I*B*a**2*exp(4*I*e))/(4*c**4), True))

Maxima [F(-2)]

Exception generated. \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^4,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 190 vs. \(2 (75) = 150\).

Time = 0.89 (sec) , antiderivative size = 190, normalized size of antiderivative = 2.09 \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=-\frac {2 \, {\left (3 \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{7} + 6 i \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{6} - 3 \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{6} - 17 \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{5} - 16 i \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} + 6 \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} + 17 \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + 6 i \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 3 \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 3 \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )\right )}}{3 \, c^{4} f {\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}^{8}} \]

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^4,x, algorithm="giac")

[Out]

-2/3*(3*A*a^2*tan(1/2*f*x + 1/2*e)^7 + 6*I*A*a^2*tan(1/2*f*x + 1/2*e)^6 - 3*B*a^2*tan(1/2*f*x + 1/2*e)^6 - 17*
A*a^2*tan(1/2*f*x + 1/2*e)^5 - 16*I*A*a^2*tan(1/2*f*x + 1/2*e)^4 + 6*B*a^2*tan(1/2*f*x + 1/2*e)^4 + 17*A*a^2*t
an(1/2*f*x + 1/2*e)^3 + 6*I*A*a^2*tan(1/2*f*x + 1/2*e)^2 - 3*B*a^2*tan(1/2*f*x + 1/2*e)^2 - 3*A*a^2*tan(1/2*f*
x + 1/2*e))/(c^4*f*(tan(1/2*f*x + 1/2*e) + I)^8)

Mupad [B] (verification not implemented)

Time = 8.45 (sec) , antiderivative size = 78, normalized size of antiderivative = 0.86 \[ \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^4} \, dx=\frac {a^2\,\left (3\,B\,{\mathrm {tan}\left (e+f\,x\right )}^2+2\,A\,\mathrm {tan}\left (e+f\,x\right )-A\,1{}\mathrm {i}\right )}{6\,c^4\,f\,\left ({\mathrm {tan}\left (e+f\,x\right )}^4+{\mathrm {tan}\left (e+f\,x\right )}^3\,4{}\mathrm {i}-6\,{\mathrm {tan}\left (e+f\,x\right )}^2-\mathrm {tan}\left (e+f\,x\right )\,4{}\mathrm {i}+1\right )} \]

[In]

int(((A + B*tan(e + f*x))*(a + a*tan(e + f*x)*1i)^2)/(c - c*tan(e + f*x)*1i)^4,x)

[Out]

(a^2*(2*A*tan(e + f*x) - A*1i + 3*B*tan(e + f*x)^2))/(6*c^4*f*(tan(e + f*x)^3*4i - 6*tan(e + f*x)^2 - tan(e +
f*x)*4i + tan(e + f*x)^4 + 1))